package com.yonyou.pmclouds.projectpart.configration;

import com.yonyou.pmclouds.projectpart.upgrade.service.IProjectPartBusinessOperator;
import com.yonyou.pmclouds.projectpart.upgrade.service.IProjectPartUpgrade;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.stereotype.Component;

/**
 * @author th
 * @date 2020/4/18 9:41
 */
@Component
public class ProjectPartBeanPostProcessor implements BeanPostProcessor {
    @Autowired
    private IProjectPartUpgrade projectPartUpgrade;

    @Override
    public Object postProcessBeforeInitialization(Object o, String s) throws BeansException {
        return o;
    }

    @Override
    public Object postProcessAfterInitialization(Object o, String s) throws BeansException {
        if (o instanceof IProjectPartBusinessOperator)
            projectPartUpgrade.addBusinessOperatorClass((IProjectPartBusinessOperator) o);

        return o;
    }
}
